/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package psc;

/**
 *
 * @author Taeko
 */
public class sinais {
    
    private double periodo;
    private double amplitude;
    private double offset;
    private double tempo;
    private double ams;
    private double saida;
    
    public sinais(){
        
    }
    
    public sinais(double periodo, double amplitude, double offset){
        this.amplitude = amplitude;
        this.periodo = periodo;
        this.offset = offset;
        this.tempo = 0;
        this.ams=0;
        this.saida = 0;
    }
    
    public double ondaQuadrada(){
        if (getTempo() < getPeriodo()/2){
            setSaida(amplitude);
        }else{
            setSaida(-amplitude);
        }
        atualizar();
        return getSaida();
    }

    public double getAmplitude() {
        return amplitude;
    }

    public void setAmplitude(double amplitude) {
        this.amplitude = amplitude;
    }

    public void atualizar(){
        
        setAms();
        setTempo(getTempo()+0.1);

        if (getTempo() >= getPeriodo()) 
        {
            setTempo(getTempo()-getPeriodo());
        }
    }

    public double getAms() {
        return ams;
    }

    public void setAms() {
        this.ams += 0.1;
    }

    public double getOffset() {
        return offset;
    }

    public void setOffset(double offset) {
        this.offset = offset;
    }

    public double getPeriodo() {
        return periodo;
    }

    public void setPeriodo(double periodo) {
        this.periodo = periodo;
    }

    public double getTempo() {
        return tempo;
    }

    public void setTempo(double tempo) {
        this.tempo = tempo;
    }

    public double getSaida() {
        return saida;
    }

    public void setSaida(double saida) {
        this.saida = saida;
    }
    
}
